import React from 'react';
import { uDb, uPrint, cline, NuiBt } from 'sui';

const OptView = ({ hreturn }) => {

    const hok = () => {
        uDb(null, "cera/list",
            {
                line: cline(),
            },
            r => {
                const getVal = (v) => {
                    if (v > 0) {
                        return `+${v}`
                    }

                    return `${v}`;
                };

                r.forEach(d => {
                    const cmd = {
                        qr: d.qr,
                        sn: d.sn,
                        ball: "" + d.ball,
                        std: getVal(d.std),
                        sub: getVal(d.sub),
                        tmpl: "t",
                    };

                    console.log(cmd);

                    uPrint(null, cmd, null, null, false);
                    uPrint(null, cmd, null, null, false);
                });
            });
    };

    return (
        <div className="flex flex-col ml-2 mr-1">
            <NuiBt hcmd={hok}>Print</NuiBt>
        </div>
    );
};

export {OptView};
